# Maintainer: omni <omni+alpine@hack.org>
maintainer="omni <omni+alpine@hack.org>"
pkgname=godap
pkgver=2.8.0
pkgrel=0
pkgdesc="A complete TUI for LDAP"
url="https://github.com/Macmod/godap"
license="MIT"
arch="all"
makedepends="go"
subpackages="$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
options="net"
source="$pkgname-$pkgver.tar.gz::https://github.com/Macmod/godap/archive/refs/tags/v$pkgver.tar.gz"

export GOFLAGS="$GOFLAGS -trimpath -mod=readonly -modcacherw"
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build \
		-ldflags="-linkmode=external -extldflags \"$LDFLAGS\"" \
		-v .

	local shell; for shell in bash fish powershell zsh; do
		./godap completion "$shell" > "$pkgname"_"$shell"
	done
}

check() {
	# no upstream tests
	./godap version
}

package() {
	install -Dm0755 "$pkgname" -t "$pkgdir"/usr/bin

	install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/"$pkgname"/LICENSE
	install -Dm644 README.md "$pkgdir"/usr/share/doc/"$pkgname"/README.md

	install -Dm644 "$pkgname"_bash "$pkgdir"/usr/share/bash-completion/completions/"$pkgname"
	install -Dm644 "$pkgname"_fish "$pkgdir"/usr/share/fish/vendor_completions.d/"$pkgname".fish
	install -Dm644 "$pkgname"_zsh "$pkgdir"/usr/share/zsh/site-functions/_"$pkgname"
}

sha512sums="
4387769b9d4bf0bdc065e820a16417b12d3deb30bcc8ae1d515c67d98dc81494985bb357c975c0bf04a4f3f600f4e464f0e7353fe103a07c9c6b3d70fd85dc5f  godap-2.8.0.tar.gz
"
